<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="../ct-step-failure.html">

<script>
(function () {

var assert = chai.assert;

describe('CTStepFailure', function() {
  var tests = [
    {
      failure: new CTStepFailure('browser_tests', 'FooTest.Bar', {}, 123, 123),
      expectedGroupName: 'FooTest',
      expectedKey: 'browser_tests::FooTest.Bar',
    },
    {
      failure: new CTStepFailure('webkit_tests', 'fast/text/foo.html', {}, 123, 123),
      expectedGroupName: 'fast/text',
      expectedKey: 'webkit_tests::fast/text/foo.html',
    },
    {
      failure: new CTStepFailure('compile', undefined, {builder1: {}}, 123, 123),
      expectedGroupName: undefined,
      expectedKey: 'compile::builder1',
    }
  ];

  it('group name', function() {
    tests.forEach(function(test) {
      assert.equal(test.failure.reasonGroupName(), test.expectedGroupName);
    });
  });

  it('has key', function() {
    tests.forEach(function(test) {
      assert.propertyVal(test.failure, 'key', test.expectedKey);
    });
  });

  it('no tree closers', function() {
    var failure = new CTStepFailure('browser_tests', 'FooTest.Bar', {}, 123, 123);
    assert.notOk(failure.isTreeCloser());
  });

  it('tree closer', function() {
    var failure = new CTStepFailure('browser_tests', 'FooTest.Bar', {'builder': {isTreeCloser: true}}, 123, 123);
    assert.ok(failure.isTreeCloser());
  });

});

})();
</script>
